package com.fang.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fang.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Fang Ruichuan
 * @date 2022-08-27 21:48
 */
@RestController
public class BaseController {

    @Autowired
    protected HttpServletRequest request;

    @Autowired
    protected SysUserService sysUserService;

    @Autowired
    protected SysRoleService sysRoleService;

    @Autowired
    protected SysMenuService sysMenuService;

    @Autowired
    protected SysUserRoleService sysUserRoleService;

    @Autowired
    protected SysRoleMenuService sysRoleMenuService;

    /**
     * 获取分页
     * @author Fang Ruichuan
     * @date 2022/9/8 20:46
     * @return Page
     */
    public Page getPage() {
        int current = ServletRequestUtils.getIntParameter(request, "current", 1);
        int pageSize = ServletRequestUtils.getIntParameter(request, "pageSize", 10);
        return new Page(current, pageSize);
    }

}
